#!/bin/sh

# Purpose : Testing script for zypper (opensuse) support
# Author  : Ky-Anh Huynh
# License : MIT

im opensuse/leap:15.2
im opensuse/leap:42.3

# FIXME: We disable this but also create a specific test from
# FIXME: github/workflow (zypper-seccomp). We should re-enable
# FIXME: this once the upstream issues are gone
# im opensuse/tumbleweed:latest

# im opensuse/clair:latest
im zypper_bash3

# On zypper_bash3, Bash is not available
in ! PACAPT_DEBUG=auto pacman
in ! if bash --version | grep -qs 'version 3'; then echo "Bash3-no-switching"; fi
ou (debug.*Switching to Bash shell)|(Bash3-no-switching)

in -P
ou available operations:.*( [Q][ ilos])+

# Update package databases
in -Sy

# Simple query that lists all packages
in -Qq
ou ^glibc
ou ^zypper

# Listing with version and package name
in -Q
# ou ^ii +zypper +.+ubuntu
ou ^i\+ +\| +zypper +

# Information of `zypper`
in -Qi zypper
ou ^Name +: +zypper
ou ^Source package : zypper-.*.src

# File listing for `zypper`
in -Ql zypper
ou ^/usr/lib/zypper/commands

# Look up package name
in -Qo /bin/bash
ou ^bash.*

in -Qo bash
ou ^bash.*

# Search for pattern in installed package (names + descriptions)
in -Qs bash
ou Bourne-Again Shell

in -Qsq bash
ou ^bash

in -Qs bourne
ou Bourne-Again Shell

in -Qs screen
ou ncurses-utils

# Install and Deinstall a package

# Download without installation
in ! pacman -Sw --noconfirm screen
in ! command -v screen || echo 'command not found'
ou command not found

# Display remote package information
in -Si screen
ou ^Name +: +screen

#in -Sii screen
#ou ^Reverse Depends:

# # Now installation
in ! pacman -S --noconfirm screen
in ! command -v screen
ou ^(/usr)?/bin/screen

# Now remove the package
in ! pacman -R --noconfirm screen
in -Qi screen
ou ^Status +: +not installed

in -Sc
ou All repositories have been cleaned up.

in -sS tmux
ou tmux

# Package groups
in -Sg
ou ^  | base
ou ^  | console

in -Sg console
ou ^  | patterns-base-console
ou ^  | tmux
